home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_13_1986_Transactor_Publishing.d64
/
pythago triplets
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
439b
|
16 lines
100 rem pythagorean triplets by rai -86
110 print"[147] u v u^2-v^2 2uv u^2+v^2"
120 print" ====================================="
130 n=10: rem number of solutions
140 dim a(n-1),b(n-1),c(n-1)
150 quit=n: j=0: u=2: v=1
160 u2=u*u: v2=v*v
170 a(j)=u2-v2: b(j)=2*u*v: c(j)=u2+v2
180 print tab(2);u;tab(6);v;tab(15);a(j);tab(25);b(j);tab(34);c(j)
190 j=j+1: if j=quit then end
200 if u-v = 1 then goto 220
210 v=v+2: goto 160
220 u=u+1: v=1
230 if (u and 1)=1 then v=2
240 goto 160